package com.zh.webflux.auth;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Set;

/**
 * @Author ZH
 * @Date 15:42 2020/9/24
 */
@Builder
@Getter
@Setter
public class UserInfo implements UserDetails, Serializable {

    private String username;

    @JsonIgnore
//    @JSONField(serialize = false)
    private String password;

    private String nickname;

    private String avatar;

    private Set<SimpleGrantedAuthority> authorities;

    public UserInfo(String username) {
        this.username = username;
    }

    public UserInfo(String username, String password, String nickname, String avatar, Set<SimpleGrantedAuthority> authorities) {
        this.username = username;
        this.password = password;
        this.nickname = nickname;
        this.avatar = avatar;
        this.authorities = authorities;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

}
